  // 回到顶部
  let returntop = document.querySelector(".return-top");
  window.addEventListener("scroll", function() {
      // console.log(window.scrollY);
      if (this.window.scrollY >= 500) {
          returntop.style.display = "block"
      } else {
          returntop.style.display = "none"
      }
  })
  returntop.addEventListener("mouseenter", function() {
      this.style.backgroundPositionY = "-98px"
  })
  returntop.addEventListener("mouseleave", function() {
      this.style.backgroundPositionY = "-56px"
  })
  let timerId = null;
  returntop.addEventListener("click", function() {
      //   clearInterval(timerId);
      timerId = window.setInterval(function() {
          document.documentElement.scrollTop -= 100;
          if (document.documentElement.scrollTop <= 0) {
              clearInterval(timerId)
              timerId = null;
          }
      }, 30)
  })

  //   封装函数模态框
  let mask = document.querySelector('.mask')

  function generateLogin(fatherDom) {
      let htmlStr = `
    <div class="login-main">
    <!-- logo图标 -->
    <div class="logobox">
        <a href="index.html">
            <img src="./images/loginlogo.png" alt="">
        </a>
    </div>
    <!-- 账号登录区域 -->
    <div class="tab">
        <!-- 头部 -->
        <ul class="tab-top clearfix">
            <li class="fl top-item active">账号登录</li>
            <li class="fl line"></li>
            <li class="fl top-item">扫码登录</li>
        </ul>
        <div class=" tab-content">
            <!-- 帐号登录盒子 -->
            <div class="con-item current">
                <form action="#" class="login-form">
                    <!-- 用户名 -->
                    <div class="user-info user-name">
                        <input class="name-inp" type="text" id="userName" name="username" value="" placeholder="用户名/手机号/邮箱">
                        <img id="clearUserName" src="./images/clearInput.png" alt="清除">
                    </div>
                    <!-- 密码 -->
                    <div class="user-info user-psd">
                        <input class="psd-inp" type="password" id="userPsd" name="userpassword" value="" placeholder="密码">
                        <img id="clearUserPwd" src="./images/clearInput.png" alt="清除">
                    </div>
                    <!-- 报错的时候有个红色感叹号 -->
                    <p class="error clearfix" id="sysError">
                        <label id="errIcon" class="fl err-icon"></label>
                        <span id="errMsg" class="fl"></span>
                    </p>
                    <!-- 忘记密码 -->
                    <div class="forget clearfix">
                        <a href="#" class="fr">忘记密码</a>
                    </div>
                    <input type="button" value="登录" id="loginBtn" class="login-btn">
                    <p class="have">
                        还没有源码账号，
                        <a href="./register.html">立即注册</a>
                        <span></span>
                    </p>
                </form>
            </div>
            <!-- 扫码登录二维码 -->
            <div class="con-item">
                <div class="item-content">
                    <img src="./images/showqrcode.jpg" alt="">
                    <p>微信扫码登录</p>
                    <p>未关注源码科技公众号，请先关注后再登录</p>
                </div>
                <p class="have">
                    还没有源码账号，
                    <a href="./register.html">立即注册</a>
                    <span></span>
                </p>
            </div>
        </div>
    </div>
</div>
    `
      fatherDom.innerHTML = htmlStr
  }
  mask.addEventListener('click', function(e) {
      console.log(e.target)
      if (e.target.className === 'mask') {
          mask.style.display = 'none'
      }
  })